\section{Include/DataProcessing.h File Reference}
\label{_data_processing_8h}\index{Include/DataProcessing.h@{Include/DataProcessing.h}}


This file contains the headers for data processing methods to be used for input and output data being passed to and from a neural network.  


{\ttfamily \#include $<$cstdlib$>$}\par
{\ttfamily \#include $<$cstdio$>$}\par
\subsection*{Defines}
\begin{DoxyCompactItemize}
\item 
\#define {\bfseries SCALE\_\-MIN}~0.05\label{_data_processing_8h_a85dac9b72eab21d3a46682ef2431625f}

\item 
\#define {\bfseries SCALE\_\-MAX}~0.05\label{_data_processing_8h_a83c9631ddffd4d9a359580726b58310b}

\end{DoxyCompactItemize}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
{\footnotesize template$<$typename numType $>$ }\\void {\bf NormalizeDataCols} (numType $\ast$$\ast$rawData, numType $\ast$$\ast$normalizedData, numType $\ast$offsets, numType $\ast$scaleFactors, int numRows, int numCols)
\item 
{\footnotesize template$<$typename numType $>$ }\\void {\bf NormalizeDataRows} (numType $\ast$$\ast$rawData, numType $\ast$$\ast$normalizedData, numType $\ast$offsets, numType $\ast$scaleFactors, int numRows, int numCols)
\item 
{\footnotesize template$<$typename numType $>$ }\\void {\bf UnNormalizeDataCols} (numType $\ast$$\ast$normalizedData, numType $\ast$$\ast$unNormalizedData, numType $\ast$offsets, numType $\ast$scaleFactors, int numRows, int numCols)
\item 
{\footnotesize template$<$typename numType $>$ }\\void {\bf UnNormalizeDataRows} (numType $\ast$$\ast$normalizedData, numType $\ast$$\ast$unNormalizedData, numType $\ast$offsets, numType $\ast$scaleFactors, int numRows, int numCols)
\item 
{\footnotesize template$<$typename numType $>$ }\\void {\bf ComputeFirstDerivative} (numType $\ast$data, numType $\ast$derivative, int numElem)
\item 
{\footnotesize template$<$typename numType $>$ }\\void {\bf ComputeSecondDerivative} (numType $\ast$data, numType $\ast$derivative, int numElem)
\item 
{\footnotesize template$<$typename numType $>$ }\\int $\ast$ {\bf FindLargestMembersInRow} (numType $\ast$$\ast$data, int searchRow, int numToFind, int numRows, int numCols)
\item 
{\footnotesize template$<$typename numType $>$ }\\int $\ast$ {\bf FindSmallestMembersInRow} (numType $\ast$$\ast$data, int searchRow, int numToFind, int numRows, int numCols)
\item 
{\footnotesize template$<$typename numType $>$ }\\int $\ast$ {\bf FindLargestMembersInCol} (numType $\ast$$\ast$data, int searchCol, int numToFind, int numRows, int numCols)
\item 
{\footnotesize template$<$typename numType $>$ }\\int $\ast$ {\bf FindSmallestMembersInCol} (numType $\ast$$\ast$data, int searchCol, int numToFind, int numRows, int numCols)
\end{DoxyCompactItemize}


\subsection{Detailed Description}
This file contains the headers for data processing methods to be used for input and output data being passed to and from a neural network. \begin{DoxyAuthor}{Author}
Thomas Fu $<${\tt thomas.ks.fu@gmail.com}$>$ 

Ben Treweek $<${\tt btreweek@gmail.com}$>$ 
\end{DoxyAuthor}
\begin{DoxyVersion}{Version}
0.0.1 
\end{DoxyVersion}
\begin{DoxyDate}{Date}
06/02/2011
\end{DoxyDate}
\subsection{License}\label{_i_o_data_types_8h_License}
This program is propety of Jyeah Jyeah Jyeah Jyeah Jyeah and may not be used by any individual for any purpose at any time without express permission from Mike Casey, Thomas Fu, Chris Hairfield, Kyle Lamson, Ben Treweek, or Cliff Warren. 

\subsection{Function Documentation}
\index{DataProcessing.h@{DataProcessing.h}!ComputeFirstDerivative@{ComputeFirstDerivative}}
\index{ComputeFirstDerivative@{ComputeFirstDerivative}!DataProcessing.h@{DataProcessing.h}}
\subsubsection[{ComputeFirstDerivative}]{\setlength{\rightskip}{0pt plus 5cm}template$<$typename numType $>$ void ComputeFirstDerivative (
\begin{DoxyParamCaption}
\item[{numType $\ast$}]{data, }
\item[{numType $\ast$}]{derivative, }
\item[{int}]{numElem}
\end{DoxyParamCaption}
)}\label{_data_processing_8h_af654da26a8d33f312b4491d5dd61c340}
Function that numerically computes the first derivative (up to a scaling factor) of the values contained in data and places the results in derivative. The derivative computations are O(h) or O(h$^\wedge$2) for speed and assume evenly spaced gridpoints.


\begin{DoxyTemplParams}{Template Parameters}
{\em numType} & The data type used to represent the numerical data. In most use cases will either be a float or a double. Templatized here for the sake of being generic.\\
\hline
\end{DoxyTemplParams}

\begin{DoxyParams}{Parameters}
{\em data} & A one dimensional array containing the numeric data to be differentiated. Space for this array will be allocated in this function.\\
\hline
{\em derivative} & A one dimensional array containing the numeric derivative of the values contained in data. Derivatives are computed up to a scale factor since the spacing of the grid points is not necessarily known\\
\hline
{\em numElem} & An integer value specifying the number of elements in the data array. \\
\hline
\end{DoxyParams}
\index{DataProcessing.h@{DataProcessing.h}!ComputeSecondDerivative@{ComputeSecondDerivative}}
\index{ComputeSecondDerivative@{ComputeSecondDerivative}!DataProcessing.h@{DataProcessing.h}}
\subsubsection[{ComputeSecondDerivative}]{\setlength{\rightskip}{0pt plus 5cm}template$<$typename numType $>$ void ComputeSecondDerivative (
\begin{DoxyParamCaption}
\item[{numType $\ast$}]{data, }
\item[{numType $\ast$}]{derivative, }
\item[{int}]{numElem}
\end{DoxyParamCaption}
)}\label{_data_processing_8h_aac0f38fc96a6003277b58aaca928e82d}
Function that numerically computes the second derivative (up to a scaling factor) of the values contained in data and places the results in derivative. The derivative computations are O(h) or O(h$^\wedge$2) for speed and assume evenly spaced gridpoints. Calculated by a different method than just two successive calculations of first derivatives in order to improve speed and accuracy.


\begin{DoxyTemplParams}{Template Parameters}
{\em numType} & The data type used to represent the numerical data. In most use cases will either be a float or a double. Templatized here for the sake of being generic.\\
\hline
\end{DoxyTemplParams}

\begin{DoxyParams}{Parameters}
{\em data} & A one dimensional array containing the numeric data to be differentiated. Space for this array will be allocated in this function.\\
\hline
{\em derivative} & A one dimensional array containing the numeric second derivative of the values contained in data. Derivatives are computed up to a scale factor since the spacing of the grid points is not necessarily known\\
\hline
{\em numElem} & An integer value specifying the number of elements in the data array. \\
\hline
\end{DoxyParams}
\index{DataProcessing.h@{DataProcessing.h}!FindLargestMembersInCol@{FindLargestMembersInCol}}
\index{FindLargestMembersInCol@{FindLargestMembersInCol}!DataProcessing.h@{DataProcessing.h}}
\subsubsection[{FindLargestMembersInCol}]{\setlength{\rightskip}{0pt plus 5cm}template$<$typename numType $>$ int$\ast$ FindLargestMembersInCol (
\begin{DoxyParamCaption}
\item[{numType $\ast$$\ast$}]{data, }
\item[{int}]{searchCol, }
\item[{int}]{numToFind, }
\item[{int}]{numRows, }
\item[{int}]{numCols}
\end{DoxyParamCaption}
)}\label{_data_processing_8h_acde1c432c5d634fc4ad6021155bd9ee1}
Function that returns an array of integers corresponding to the indicies of the largest numToFind elements of the column of data specified by searchCol. The elements of the returned array of ints should be in sorted order such that the first element is the index of the largest element. If searchCol is out of bounds, this function will return NULL. If numToFind is greater than or equal to the number of rows of data the returned array simply contains the indices of all elements from largest to smallest.


\begin{DoxyTemplParams}{Template Parameters}
{\em numType} & The data type used to represent the numerical data. In most use cases will either be a float or a double. Templatized here for the sake of being generic.\\
\hline
\end{DoxyTemplParams}

\begin{DoxyParams}{Parameters}
{\em data} & A two dimensional array containing the numeric data to be searched.\\
\hline
{\em searchCol} & The column of data to be searched for the largest values\\
\hline
{\em numToFind} & The number of largest elements to find. For instance, if numToFind is five, then this function should return the indices of the five largest elements.\\
\hline
{\em numRows} & The number of rows in rawData\\
\hline
{\em numCols} & The number of columns in rawData\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
An array containing the indices of the largest elements in searchCol sorted such that the first element of this array corresponds to the largest element. 
\end{DoxyReturn}
\index{DataProcessing.h@{DataProcessing.h}!FindLargestMembersInRow@{FindLargestMembersInRow}}
\index{FindLargestMembersInRow@{FindLargestMembersInRow}!DataProcessing.h@{DataProcessing.h}}
\subsubsection[{FindLargestMembersInRow}]{\setlength{\rightskip}{0pt plus 5cm}template$<$typename numType $>$ int$\ast$ FindLargestMembersInRow (
\begin{DoxyParamCaption}
\item[{numType $\ast$$\ast$}]{data, }
\item[{int}]{searchRow, }
\item[{int}]{numToFind, }
\item[{int}]{numRows, }
\item[{int}]{numCols}
\end{DoxyParamCaption}
)}\label{_data_processing_8h_a5ddbf666d08595c2aecaf7918f18d1dc}
Function that returns an array of integers corresponding to the indicies of the largest numToFind elements of the row of data specified by searchRow. The elements of the returned array of ints should be in sorted order such that the first element is the index of the largest element. If searchRow is out of bounds, this function will return NULL. If numToFind is greater than or equal to the number of columns of data the returned array simply contains the indices of all elements from largest to smallest.


\begin{DoxyTemplParams}{Template Parameters}
{\em numType} & The data type used to represent the numerical data. In most use cases will either be a float or a double. Templatized here for the sake of being generic.\\
\hline
\end{DoxyTemplParams}

\begin{DoxyParams}{Parameters}
{\em data} & A two dimensional array containing the numeric data to be searched.\\
\hline
{\em searchRow} & The row of data to be searched for the largest values\\
\hline
{\em numToFind} & The number of largest elements to find. For instance, if numToFind is five, then this function should return the indices of the five largest elements.\\
\hline
{\em numRows} & The number of rows in rawData\\
\hline
{\em numCols} & The number of columns in rawData\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
An array containing the indices of the largest elements in searchRow sorted such that the first element of this array corresponds to the largest element. 
\end{DoxyReturn}
\index{DataProcessing.h@{DataProcessing.h}!FindSmallestMembersInCol@{FindSmallestMembersInCol}}
\index{FindSmallestMembersInCol@{FindSmallestMembersInCol}!DataProcessing.h@{DataProcessing.h}}
\subsubsection[{FindSmallestMembersInCol}]{\setlength{\rightskip}{0pt plus 5cm}template$<$typename numType $>$ int$\ast$ FindSmallestMembersInCol (
\begin{DoxyParamCaption}
\item[{numType $\ast$$\ast$}]{data, }
\item[{int}]{searchCol, }
\item[{int}]{numToFind, }
\item[{int}]{numRows, }
\item[{int}]{numCols}
\end{DoxyParamCaption}
)}\label{_data_processing_8h_a7a02368c6cece952a282ed0325f77f78}
Function that returns an array of integers corresponding to the indicies of the smallest numToFind elements of the column of data specified by searchCol. The elements of the returned array of ints should be in sorted order such that the first element is the index of the smallest element. If searchCol is out of bounds, this function will return NULL. If numToFind is greater than or equal to the number of rows of data the returned array simply contains the indices of all elements from smallest to largest.


\begin{DoxyTemplParams}{Template Parameters}
{\em numType} & The data type used to represent the numerical data. In most use cases will either be a float or a double. Templatized here for the sake of being generic.\\
\hline
\end{DoxyTemplParams}

\begin{DoxyParams}{Parameters}
{\em data} & A two dimensional array containing the numeric data to be searched.\\
\hline
{\em searchCol} & The column of data to be searched for the smallest values\\
\hline
{\em numToFind} & The number of smallest elements to find. For instance, if numToFind is five, then this function should return the indices of the five smallest elements.\\
\hline
{\em numRows} & The number of rows in rawData\\
\hline
{\em numCols} & The number of columns in rawData\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
An array containing the indices of the smallest elements in searchCol sorted such that the first element of this array corresponds to the smallest element. 
\end{DoxyReturn}
\index{DataProcessing.h@{DataProcessing.h}!FindSmallestMembersInRow@{FindSmallestMembersInRow}}
\index{FindSmallestMembersInRow@{FindSmallestMembersInRow}!DataProcessing.h@{DataProcessing.h}}
\subsubsection[{FindSmallestMembersInRow}]{\setlength{\rightskip}{0pt plus 5cm}template$<$typename numType $>$ int$\ast$ FindSmallestMembersInRow (
\begin{DoxyParamCaption}
\item[{numType $\ast$$\ast$}]{data, }
\item[{int}]{searchRow, }
\item[{int}]{numToFind, }
\item[{int}]{numRows, }
\item[{int}]{numCols}
\end{DoxyParamCaption}
)}\label{_data_processing_8h_aa0255a362aadccb4a0e97ef9477b6c87}
Function that returns an array of integers corresponding to the indicies of the smallest numToFind elements of the row of data specified by searchRow. The elements of the returned array of ints should be in sorted order such that the first element is the index of the smallest element. If searchRow is out of bounds, this function will return NULL. If numToFind is greater than or equal to the number of columns of data the returned array simply contains the indices of all elements from smallest to largest.


\begin{DoxyTemplParams}{Template Parameters}
{\em numType} & The data type used to represent the numerical data. In most use cases will either be a float or a double. Templatized here for the sake of being generic.\\
\hline
\end{DoxyTemplParams}

\begin{DoxyParams}{Parameters}
{\em data} & A two dimensional array containing the numeric data to be searched.\\
\hline
{\em searchRow} & The row of data to be searched for the smallest values\\
\hline
{\em numToFind} & The number of smallest elements to find. For instance, if numToFind is five, then this function should return the indices of the five smallest elements.\\
\hline
{\em numRows} & The number of rows in rawData\\
\hline
{\em numCols} & The number of columns in rawData\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
An array containing the indices of the smallest elements in searchRow sorted such that the first element of this array corresponds to the smallest element. 
\end{DoxyReturn}
\index{DataProcessing.h@{DataProcessing.h}!NormalizeDataCols@{NormalizeDataCols}}
\index{NormalizeDataCols@{NormalizeDataCols}!DataProcessing.h@{DataProcessing.h}}
\subsubsection[{NormalizeDataCols}]{\setlength{\rightskip}{0pt plus 5cm}template$<$typename numType $>$ void NormalizeDataCols (
\begin{DoxyParamCaption}
\item[{numType $\ast$$\ast$}]{rawData, }
\item[{numType $\ast$$\ast$}]{normalizedData, }
\item[{numType $\ast$}]{offsets, }
\item[{numType $\ast$}]{scaleFactors, }
\item[{int}]{numRows, }
\item[{int}]{numCols}
\end{DoxyParamCaption}
)}\label{_data_processing_8h_aec0087ad09b50e6257807e5401e822c9}
Function that scales a two dimensional array of either floats or doubles such that all of the values in each column are between SCALE\_\-MIN and SCALE\_\-MAX. This is achieved column-\/by-\/column by subtracting the minimum value in each column from every value in that column, multilpying each value in that column by the multiplicative inverse of the largest value in that column, and finally by adding SCALE\_\-MIN to each value in that column.


\begin{DoxyTemplParams}{Template Parameters}
{\em numType} & The data type used to represent the numerical data. In most use cases will either be a float or a double. Templatized here for the sake of being generic.\\
\hline
\end{DoxyTemplParams}

\begin{DoxyParams}{Parameters}
{\em rawData} & A two dimensional array of raw numerical data. Assumed to be rectangular\\
\hline
{\em normalizedData} & A two dimensional array containing the normalized version of the raw data (should have the same dimensions as rawData). Space for this data is allocated by NormalizeData.\\
\hline
{\em offsets} & A one dimensional array of numCols elements, such that each element of offsets is the minimum value in each column. Space for this array is allocated in NormalizeData.\\
\hline
{\em scaleFactors} & A one dimensional array of numCols elements such that each element of scaleFactors corresponds to one divided by the largest value in each column. Space for this array is allocated in NormalizeData.\\
\hline
{\em numRows} & The number of rows in rawData\\
\hline
{\em numCols} & The number of columns in rawData \\
\hline
\end{DoxyParams}
\index{DataProcessing.h@{DataProcessing.h}!NormalizeDataRows@{NormalizeDataRows}}
\index{NormalizeDataRows@{NormalizeDataRows}!DataProcessing.h@{DataProcessing.h}}
\subsubsection[{NormalizeDataRows}]{\setlength{\rightskip}{0pt plus 5cm}template$<$typename numType $>$ void NormalizeDataRows (
\begin{DoxyParamCaption}
\item[{numType $\ast$$\ast$}]{rawData, }
\item[{numType $\ast$$\ast$}]{normalizedData, }
\item[{numType $\ast$}]{offsets, }
\item[{numType $\ast$}]{scaleFactors, }
\item[{int}]{numRows, }
\item[{int}]{numCols}
\end{DoxyParamCaption}
)}\label{_data_processing_8h_a61119433ec491b2bb32da07a049e0a25}
Function that scales a two dimensional array of either floats or doubles such that all of the values in each row are between SCALE\_\-MIN and SCALE\_\-MAX. This is achieved row-\/by-\/row by subtracting the minimum value in each row from every value in that row, multilpying each value in that row by the multiplicative inverse of the largest value in that row, and finally by adding SCALE\_\-MIN to each value in that row.


\begin{DoxyTemplParams}{Template Parameters}
{\em numType} & The data type used to represent the numerical data. In most use cases will either be a float or a double. Templatized here for the sake of being generic.\\
\hline
\end{DoxyTemplParams}

\begin{DoxyParams}{Parameters}
{\em rawData} & A two dimensional array of raw numerical data. Assumed to be rectangular\\
\hline
{\em normalizedData} & A two dimensional array containing the normalized version of the raw data (should have the same dimensions as rawData). Space for this data is allocated by NormalizeData.\\
\hline
{\em offsets} & A one dimensional array of numRows elements, such that each element of offsets is the minimum value in each row. Space for this array is allocated in NormalizeData.\\
\hline
{\em scaleFactors} & A one dimensional array of numRows elements such that each element of scaleFactors corresponds to one divided by the largest value in each row. Space for this array is allocated in NormalizeData.\\
\hline
{\em numRows} & The number of rows in rawData\\
\hline
{\em numCols} & The number of columns in rawData \\
\hline
\end{DoxyParams}
\index{DataProcessing.h@{DataProcessing.h}!UnNormalizeDataCols@{UnNormalizeDataCols}}
\index{UnNormalizeDataCols@{UnNormalizeDataCols}!DataProcessing.h@{DataProcessing.h}}
\subsubsection[{UnNormalizeDataCols}]{\setlength{\rightskip}{0pt plus 5cm}template$<$typename numType $>$ void UnNormalizeDataCols (
\begin{DoxyParamCaption}
\item[{numType $\ast$$\ast$}]{normalizedData, }
\item[{numType $\ast$$\ast$}]{unNormalizedData, }
\item[{numType $\ast$}]{offsets, }
\item[{numType $\ast$}]{scaleFactors, }
\item[{int}]{numRows, }
\item[{int}]{numCols}
\end{DoxyParamCaption}
)}\label{_data_processing_8h_a4e2e3c962efdfeb11fe935b3d85bf9e3}
Function that unscales a two normalized dimensional array of either floats or doubles, where all of the values in each column are between SCALE\_\-MIN and SCALE\_\-MAX, by inverting the process performed in NormalizeDataCols.


\begin{DoxyTemplParams}{Template Parameters}
{\em numType} & The data type used to represent the numerical data. In most use cases will either be a float or a double. Templatized here for the sake of being generic.\\
\hline
\end{DoxyTemplParams}

\begin{DoxyParams}{Parameters}
{\em normalizedData} & A two dimensional array containing the normalized version of the raw data (in the format produced by NormalizeDataCols).\\
\hline
{\em unNormalizedData} & A two dimensional array of the inverted version of the data contained in normalizedData. This should be such that it completely inverts the process performed in NormalizeDataCols. Space for this array is allocated in UnNormalizeDataCols.\\
\hline
{\em offsets} & A one dimensional array of numCols elements, such that each element of offsets is the minimum value in each column.\\
\hline
{\em scaleFactors} & A one dimensional array of numCols elements such that each element of scaleFactors corresponds to one divided by the largest value in each column.\\
\hline
{\em numRows} & The number of rows in rawData\\
\hline
{\em numCols} & The number of columns in rawData \\
\hline
\end{DoxyParams}
\index{DataProcessing.h@{DataProcessing.h}!UnNormalizeDataRows@{UnNormalizeDataRows}}
\index{UnNormalizeDataRows@{UnNormalizeDataRows}!DataProcessing.h@{DataProcessing.h}}
\subsubsection[{UnNormalizeDataRows}]{\setlength{\rightskip}{0pt plus 5cm}template$<$typename numType $>$ void UnNormalizeDataRows (
\begin{DoxyParamCaption}
\item[{numType $\ast$$\ast$}]{normalizedData, }
\item[{numType $\ast$$\ast$}]{unNormalizedData, }
\item[{numType $\ast$}]{offsets, }
\item[{numType $\ast$}]{scaleFactors, }
\item[{int}]{numRows, }
\item[{int}]{numCols}
\end{DoxyParamCaption}
)}\label{_data_processing_8h_af06e26459dc59614d06af3f1bf0afc54}
Function that unscales a two normalized dimensional array of either floats or doubles, where all of the values in each row are between SCALE\_\-MIN and SCALE\_\-MAX, by inverting the process performed in NormalizeDataRows.


\begin{DoxyTemplParams}{Template Parameters}
{\em numType} & The data type used to represent the numerical data. In most use cases will either be a float or a double. Templatized here for the sake of being generic.\\
\hline
\end{DoxyTemplParams}

\begin{DoxyParams}{Parameters}
{\em normalizedData} & A two dimensional array containing the normalized version of the raw data (in the format produced by NormalizeDataRows).\\
\hline
{\em unNormalizedData} & A two dimensional array of the inverted version of the data contained in normalizedData. This should be such that it completely inverts the process performed in NormalizeDataRows. Space for this array is allocated in UnNormalizeDataRows.\\
\hline
{\em offsets} & A one dimensional array of numRows elements, such that each element of offsets is the minimum value in each row.\\
\hline
{\em scaleFactors} & A one dimensional array of numRows elements such that each element of scaleFactors corresponds to one divided by the largest value in each row.\\
\hline
{\em numRows} & The number of rows in rawData\\
\hline
{\em numCols} & The number of columns in rawData \\
\hline
\end{DoxyParams}
